//package com.ct.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.scheduling.annotation.AsyncConfigurer;
//import org.springframework.scheduling.annotation.EnableAsync;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
//
//import java.util.concurrent.Executor;
//import java.util.concurrent.ThreadPoolExecutor;
//
//@Configuration
//@EnableAsync
//public class ThreadPoolConfig implements AsyncConfigurer {
//    /**
//     * 项目共用线程池
//     */
//    public static final String MALLCHAT_EXECUTOR = "mallchatExecutor";
//    /**
//     * websocket通信线程池
//     */
//    public static final String WS_EXECUTOR = "websocketExecutor";
//
//    @Override
//    public Executor getAsyncExecutor() {
//        return mallchatExecutor();
//    }
//
//    @Bean(MALLCHAT_EXECUTOR)
//    @Primary
//    public ThreadPoolTaskExecutor mallchatExecutor() {
//        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//        executor.setCorePoolSize(10);
//        executor.setMaxPoolSize(10);
//        executor.setQueueCapacity(200);
//        executor.setThreadNamePrefix("mallchat-executor-");
//        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());//满了调用线程执行，认为重要任务
//        executor.initialize();
//        return executor;
//    }
//}